MERS Analysis

This a report of the visualization examples prepared as part of IDEAS workshop day 1.

library(lubridate)
## Warning: package 'lubridate' was built under R version 3.4.4
## 
## Attaching package: 'lubridate'
## The following object is masked from 'package:base':
## 
##     date
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.4.4
library(plotly)
## Warning: package 'plotly' was built under R version 3.4.4
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
mers <- read.csv('cases.csv')
class(mers$onset)
## [1] "factor"
mers$hospitalized[890] <-('2015-02-20')
mers <- mers[-471,]
mers$onset2 <- ymd(mers$onset)
mers$hospitalized2 <- ymd(mers$hospitalized)
## Warning: 5 failed to parse.
class(mers$onset2)
## [1] "Date"
day0 <- min(na.omit(mers$onset2))
mers$epi.day <- as.numeric(mers$onset2 - day0)

Global analysis of MERS

## Warning: Removed 535 rows containing non-finite values (stat_count).

The following chart allows us to examine cases by country

## Warning: Removed 535 rows containing non-finite values (stat_count).
## Warning: position_stack requires non-overlapping x intervals

MERS infectious period

Univariate analyses

## [1] "difftime"
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 727 rows containing non-finite values (stat_bin).

The above example incluced nosocomial infections. Below we remove any cases that start before hospitalization

## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 727 rows containing non-finite values (stat_bin).

Bivariate analyses

The following replicates the orginal graphs but with nosocomial infections removed.

## Warning: Removed 727 rows containing missing values (geom_point).

The following explores data using facets (broken out my country)

## Warning: Removed 728 rows containing missing values (geom_point).

Interactive chart with plotly

## Warning: Ignoring 727 observations
## Warning: package 'bindrcpp' was built under R version 3.4.4

### Interactive chart using ggplotly

## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
## Warning: Removed 535 rows containing non-finite values (stat_count).
## Warning: position_stack requires non-overlapping x intervals